## Figure replication code for "Repelling Rape"
## Replication files for all figures except A3 and OA1 (seperate replication files available).
## 9/24/19
# Load necessary packages.
library(ggplot2)
library(lattice)
library(latticeExtra)
# Set working directory.
setwd("/Users/Helms/Dropbox/IndiaRape_FigureReplicationBen/Replication_FiguresFINALVERSION")
########################################
### Figure 1: FDI in India Over Time ###
########################################
# Load Figure 1 top panel data.
fig1top_data <- read.csv("fig1top_data.csv")
# Set panel parameters for a double-paneled figure.
par(mfrow=c(2,1))
# Plot top panel of Figure 1.
plot(fig1top_data$x~as.integer(fig1top_data$year),xlab="year",ylab="rupees (2011 constant millions)",type="l",lty=1,lwd=2, sub="Completed Greenfield FDI Projects (Source: CapEx)")
abline(v=2006,col="red",lty=1)
# Load Figure 1 bottom panel data.
fig1bot_data <- read.csv("fig1bot_data.csv")
# Plot bottom panel of Figure 1.
plot(fig1bot_data$x~fig1bot_data$year,xlab="year",ylab=" US$ (millions)",type="l",lty=2,lwd=2,sub=" Official Data on Greenfield FDI Inflows (Source: RBI)")
abline(v=2006,col="red",lty=1)
#################################################
### Figure 2: FDI in India Over Time By Route ###
#################################################
# Reset panel parameters for the figure.
par(mfrow=c(1,1))
# Load data for Figure 2.
fig2_data <- read.csv("fig2_data.csv")
# Create a vector of variables for use in the figure.
vars.use <- c("a. Government (SIA/FIPB)","b. RBI","d. Acquisition of shares *","II. Reinvested earnings +" ,"c. NRI")
# Plot Figure 2.
plot(fig2_data[which(fig2_data$type==vars.use[2]),"value"]~fig2_data[which(fig2_data$type==vars.use[2]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=1,lwd=4)
lines(fig2_data[which(fig2_data$type==vars.use[1]),"value"]~fig2_data[which(fig2_data$type==vars.use[1]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=2,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[3]),"value"]~fig2_data[which(fig2_data$type==vars.use[3]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=3,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[4]),"value"]~fig2_data[which(fig2_data$type==vars.use[4]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=4,lwd=2)
leg.tfig2_datat=c("automatic route","government route","acqusition","reinvested earnings")
legend("topleft",lty=c(1,2,3,4),col=c("black","black","black","black"),lwd=c(4,2,2,2,2),leg.tfig2_datat,bty="n")
###################################################################
### Figure 3: FDI in India over Time: Treated vs Control States ###
###################################################################
# Load data for Figure 3.
fig3_data <- read.csv("fig3_data.csv")
# Plot Figure 3.
plot(fig3_data[which(fig3_data$assign=="treated"),"x"]~fig3_data[which(fig3_data$assign=="treated"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=1,lwd=2,ylim=c(0,200000))
lines(fig3_data[which(fig3_data$assign=="control"),"x"]~fig3_data[which(fig3_data$assign=="control"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=2,lwd=2,ylim=c(0,200000))
leg.txt=c("treatment","control")
legend("topleft",lty=c(1,2),col=c("black","black"),lwd=c(2,2),leg.txt,bty="n")
##############################################################################################
### Appendix Figure A.1: Share of Total Greenfield FDI received by High FDI-Exposed States ###
##############################################################################################
# Load data for Figure A.1.
figa1_data <- read.csv("figa1_data.csv")
# Plot Figure A.1.
ggplot(figa1_data, aes(x=year, y = pct_deflamt, fill = assign)) +
geom_bar(stat = "identity") +
xlab("year") + ylab("% FDI inflows") +
scale_fill_manual("Indian States:",
values = c("control" = "gray", "treated" = "black"),
labels = c("low FDI recipients (\"control\")", "high FDI recipients (\"treated\")")) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")) +
theme(legend.position="bottom",
legend.box = "horizontal",
legend.title = element_text(size=12),
legend.text=element_text(size=11)) +
scale_x_continuous(breaks=seq(1992, 2004, by=2))
##########################################################
### Appendix Figure A.2: FDI Rises Post Liberalization ###
##########################################################
# Load data for Figure A.2.
figa2_data1 <- read.csv("figa2_data1.csv") # FDI restrictions
figa2_data2 <- read.csv("figa2_data2.csv") # FDI inflows
# Plot over-time changes in median foreign ownership restrictions.
regs <- xyplot(x~year,data=figa2_data1,xlab="year",ylab="median foreign ownership restriction",col="black",type="l",lwd=2)
# Plot over-time changes in inflows of FDI.
flows <-  xyplot(x~year,data=figa2_data2,xlab="year",ylab="rupees (hundreds of millions)",col="red",type="l",lwd=2)
# Plot Figure A.2.
doubleYScale(flows,regs,add.ylab2=T)
update(trellis.last.object(),add.ylab2 = TRUE,
par.settings = simpleTheme(col= c("red","black")))
############################################################################
### Appendix Figure A.4: Year-by-Year Estimates of FDI’s Effects on Rape ###
############################################################################
figa4_data <- read_csv("figa4_data.csv")
ggplot(figa4_data, aes(x=year, y=coef, color=version)) +
geom_vline(xintercept = 2006.03, color="red", lty=2) +
geom_point(position=position_dodge(width=0.4)) +
geom_errorbar(aes(ymin=lb, ymax=ub), width=0, position=position_dodge(width=0.4)) +
geom_hline(yintercept = 0, alpha=.3, size=.2) +
scale_color_manual(values=c("1_no_controls"="gray75", "2_pop_2001"="gray50", "3_full_controls"="black"),
breaks=c("1_no_controls", "2_pop_2001", "3_full_controls"),
labels=c("No controls", "Control for pop. (2001)", "Controls for pop. (2001), gender\nratio, & literacy rate change"),
name="Specifications") +
scale_x_continuous(breaks=seq(2003, 2012, by=1)) +
xlab("Year") +
ylab("Coefficient") +
theme_classic() +
theme(legend.position="bottom")
## Figure replication code for "Repelling Rape"
## Replication files for all figures except A3 and OA1 (seperate replication files available).
## 9/24/19
# Load necessary packages.
library(ggplot2)
library(lattice)
library(latticeExtra)
# Set working directory.
setwd("/Users/Helms/Dropbox/IndiaRape_FigureReplicationBen/Replication_FiguresFINALVERSION")
########################################
### Figure 1: FDI in India Over Time ###
########################################
# Load Figure 1 top panel data.
fig1top_data <- read.csv("fig1top_data.csv")
# Set panel parameters for a double-paneled figure.
par(mfrow=c(2,1))
# Plot top panel of Figure 1.
plot(fig1top_data$x~as.integer(fig1top_data$year),xlab="year",ylab="rupees (2011 constant millions)",type="l",lty=1,lwd=2, sub="Completed Greenfield FDI Projects (Source: CapEx)")
abline(v=2006,col="red",lty=1)
# Load Figure 1 bottom panel data.
fig1bot_data <- read.csv("fig1bot_data.csv")
# Plot bottom panel of Figure 1.
plot(fig1bot_data$x~fig1bot_data$year,xlab="year",ylab=" US$ (millions)",type="l",lty=2,lwd=2,sub=" Official Data on Greenfield FDI Inflows (Source: RBI)")
abline(v=2006,col="red",lty=1)
#################################################
### Figure 2: FDI in India Over Time By Route ###
#################################################
# Reset panel parameters for the figure.
par(mfrow=c(1,1))
# Load data for Figure 2.
fig2_data <- read.csv("fig2_data.csv")
# Create a vector of variables for use in the figure.
vars.use <- c("a. Government (SIA/FIPB)","b. RBI","d. Acquisition of shares *","II. Reinvested earnings +" ,"c. NRI")
# Plot Figure 2.
plot(fig2_data[which(fig2_data$type==vars.use[2]),"value"]~fig2_data[which(fig2_data$type==vars.use[2]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=1,lwd=4)
lines(fig2_data[which(fig2_data$type==vars.use[1]),"value"]~fig2_data[which(fig2_data$type==vars.use[1]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=2,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[3]),"value"]~fig2_data[which(fig2_data$type==vars.use[3]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=3,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[4]),"value"]~fig2_data[which(fig2_data$type==vars.use[4]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=4,lwd=2)
leg.tfig2_datat=c("automatic route","government route","acqusition","reinvested earnings")
legend("topleft",lty=c(1,2,3,4),col=c("black","black","black","black"),lwd=c(4,2,2,2,2),leg.tfig2_datat,bty="n")
###################################################################
### Figure 3: FDI in India over Time: Treated vs Control States ###
###################################################################
# Load data for Figure 3.
fig3_data <- read.csv("fig3_data.csv")
# Plot Figure 3.
plot(fig3_data[which(fig3_data$assign=="treated"),"x"]~fig3_data[which(fig3_data$assign=="treated"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=1,lwd=2,ylim=c(0,200000))
lines(fig3_data[which(fig3_data$assign=="control"),"x"]~fig3_data[which(fig3_data$assign=="control"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=2,lwd=2,ylim=c(0,200000))
leg.txt=c("treatment","control")
legend("topleft",lty=c(1,2),col=c("black","black"),lwd=c(2,2),leg.txt,bty="n")
##############################################################################################
### Appendix Figure A.1: Share of Total Greenfield FDI received by High FDI-Exposed States ###
##############################################################################################
# Load data for Figure A.1.
figa1_data <- read.csv("figa1_data.csv")
# Plot Figure A.1.
ggplot(figa1_data, aes(x=year, y = pct_deflamt, fill = assign)) +
geom_bar(stat = "identity") +
xlab("year") + ylab("% FDI inflows") +
scale_fill_manual("Indian States:",
values = c("control" = "gray", "treated" = "black"),
labels = c("low FDI recipients (\"control\")", "high FDI recipients (\"treated\")")) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")) +
theme(legend.position="bottom",
legend.box = "horizontal",
legend.title = element_text(size=12),
legend.text=element_text(size=11)) +
scale_x_continuous(breaks=seq(1992, 2004, by=2))
##########################################################
### Appendix Figure A.2: FDI Rises Post Liberalization ###
##########################################################
# Load data for Figure A.2.
figa2_data1 <- read.csv("figa2_data1.csv") # FDI restrictions
figa2_data2 <- read.csv("figa2_data2.csv") # FDI inflows
# Plot over-time changes in median foreign ownership restrictions.
regs <- xyplot(x~year,data=figa2_data1,xlab="year",ylab="median foreign ownership restriction",col="black",type="l",lwd=2)
# Plot over-time changes in inflows of FDI.
flows <-  xyplot(x~year,data=figa2_data2,xlab="year",ylab="rupees (hundreds of millions)",col="red",type="l",lwd=2)
# Plot Figure A.2.
doubleYScale(flows,regs,add.ylab2=T)
update(trellis.last.object(),add.ylab2 = TRUE,
par.settings = simpleTheme(col= c("red","black")))
############################################################################
### Appendix Figure A.4: Year-by-Year Estimates of FDI’s Effects on Rape ###
############################################################################
figa4_data <- read.csv("figa4_data.csv")
ggplot(figa4_data, aes(x=year, y=coef, color=version)) +
geom_vline(xintercept = 2006.03, color="red", lty=2) +
geom_point(position=position_dodge(width=0.4)) +
geom_errorbar(aes(ymin=lb, ymax=ub), width=0, position=position_dodge(width=0.4)) +
geom_hline(yintercept = 0, alpha=.3, size=.2) +
scale_color_manual(values=c("1_no_controls"="gray75", "2_pop_2001"="gray50", "3_full_controls"="black"),
breaks=c("1_no_controls", "2_pop_2001", "3_full_controls"),
labels=c("No controls", "Control for pop. (2001)", "Controls for pop. (2001), gender\nratio, & literacy rate change"),
name="Specifications") +
scale_x_continuous(breaks=seq(2003, 2012, by=1)) +
xlab("Year") +
ylab("Coefficient") +
theme_classic() +
theme(legend.position="bottom")
## Figure replication code for "Repelling Rape"
## Replication files for all figures except A3 and OA1 (seperate replication files available).
## 9/24/19
# Load necessary packages.
library(ggplot2)
library(lattice)
library(latticeExtra)
# Set working directory to current folder, which contains all necessary data files.
setwd(".........../CrimeFDI_ReplicationFiles/Replication_Figures")
########################################
### Figure 1: FDI in India Over Time ###
########################################
# Load Figure 1 top panel data.
fig1top_data <- read.csv("fig1top_data.csv")
# Set panel parameters for a double-paneled figure.
par(mfrow=c(2,1))
# Plot top panel of Figure 1.
plot(fig1top_data$x~as.integer(fig1top_data$year),xlab="year",ylab="rupees (2011 constant millions)",type="l",lty=1,lwd=2, sub="Completed Greenfield FDI Projects (Source: CapEx)")
abline(v=2006,col="red",lty=1)
# Load Figure 1 bottom panel data.
fig1bot_data <- read.csv("fig1bot_data.csv")
# Plot bottom panel of Figure 1.
plot(fig1bot_data$x~fig1bot_data$year,xlab="year",ylab=" US$ (millions)",type="l",lty=2,lwd=2,sub=" Official Data on Greenfield FDI Inflows (Source: RBI)")
abline(v=2006,col="red",lty=1)
#################################################
### Figure 2: FDI in India Over Time By Route ###
#################################################
# Reset panel parameters for the figure.
par(mfrow=c(1,1))
# Load data for Figure 2.
fig2_data <- read.csv("fig2_data.csv")
# Create a vector of variables for use in the figure.
vars.use <- c("a. Government (SIA/FIPB)","b. RBI","d. Acquisition of shares *","II. Reinvested earnings +" ,"c. NRI")
# Plot Figure 2.
plot(fig2_data[which(fig2_data$type==vars.use[2]),"value"]~fig2_data[which(fig2_data$type==vars.use[2]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=1,lwd=4)
lines(fig2_data[which(fig2_data$type==vars.use[1]),"value"]~fig2_data[which(fig2_data$type==vars.use[1]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=2,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[3]),"value"]~fig2_data[which(fig2_data$type==vars.use[3]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=3,lwd=2)
lines(fig2_data[which(fig2_data$type==vars.use[4]),"value"]~fig2_data[which(fig2_data$type==vars.use[4]),"variable"],type="l",col="black",xlab="RBI fiscal year",ylab="millions US$",lty=4,lwd=2)
leg.tfig2_datat=c("automatic route","government route","acqusition","reinvested earnings")
legend("topleft",lty=c(1,2,3,4),col=c("black","black","black","black"),lwd=c(4,2,2,2,2),leg.tfig2_datat,bty="n")
###################################################################
### Figure 3: FDI in India over Time: Treated vs Control States ###
###################################################################
# Load data for Figure 3.
fig3_data <- read.csv("fig3_data.csv")
# Plot Figure 3.
plot(fig3_data[which(fig3_data$assign=="treated"),"x"]~fig3_data[which(fig3_data$assign=="treated"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=1,lwd=2,ylim=c(0,200000))
lines(fig3_data[which(fig3_data$assign=="control"),"x"]~fig3_data[which(fig3_data$assign=="control"),"year"],xlab="year",ylab="rupees (millions)",col="black",type="l",lty=2,lwd=2,ylim=c(0,200000))
leg.txt=c("treatment","control")
legend("topleft",lty=c(1,2),col=c("black","black"),lwd=c(2,2),leg.txt,bty="n")
##############################################################################################
### Appendix Figure A.1: Share of Total Greenfield FDI received by High FDI-Exposed States ###
##############################################################################################
# Load data for Figure A.1.
figa1_data <- read.csv("figa1_data.csv")
# Plot Figure A.1.
ggplot(figa1_data, aes(x=year, y = pct_deflamt, fill = assign)) +
geom_bar(stat = "identity") +
xlab("year") + ylab("% FDI inflows") +
scale_fill_manual("Indian States:",
values = c("control" = "gray", "treated" = "black"),
labels = c("low FDI recipients (\"control\")", "high FDI recipients (\"treated\")")) +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black")) +
theme(legend.position="bottom",
legend.box = "horizontal",
legend.title = element_text(size=12),
legend.text=element_text(size=11)) +
scale_x_continuous(breaks=seq(1992, 2004, by=2))
##########################################################
### Appendix Figure A.2: FDI Rises Post Liberalization ###
##########################################################
# Load data for Figure A.2.
figa2_data1 <- read.csv("figa2_data1.csv") # FDI restrictions
figa2_data2 <- read.csv("figa2_data2.csv") # FDI inflows
# Plot over-time changes in median foreign ownership restrictions.
regs <- xyplot(x~year,data=figa2_data1,xlab="year",ylab="median foreign ownership restriction",col="black",type="l",lwd=2)
# Plot over-time changes in inflows of FDI.
flows <-  xyplot(x~year,data=figa2_data2,xlab="year",ylab="rupees (hundreds of millions)",col="red",type="l",lwd=2)
# Plot Figure A.2.
doubleYScale(flows,regs,add.ylab2=T)
update(trellis.last.object(),add.ylab2 = TRUE,
par.settings = simpleTheme(col= c("red","black")))
############################################################################
### Appendix Figure A.4: Year-by-Year Estimates of FDI’s Effects on Rape ###
############################################################################
figa4_data <- read.csv("figa4_data.csv")
ggplot(figa4_data, aes(x=year, y=coef, color=version)) +
geom_vline(xintercept = 2006.03, color="red", lty=2) +
geom_point(position=position_dodge(width=0.4)) +
geom_errorbar(aes(ymin=lb, ymax=ub), width=0, position=position_dodge(width=0.4)) +
geom_hline(yintercept = 0, alpha=.3, size=.2) +
scale_color_manual(values=c("1_no_controls"="gray75", "2_pop_2001"="gray50", "3_full_controls"="black"),
breaks=c("1_no_controls", "2_pop_2001", "3_full_controls"),
labels=c("No controls", "Control for pop. (2001)", "Controls for pop. (2001), gender\nratio, & literacy rate change"),
name="Specifications") +
scale_x_continuous(breaks=seq(2003, 2012, by=1)) +
xlab("Year") +
ylab("Coefficient") +
theme_classic() +
theme(legend.position="bottom")
# Load necessary packages.
library(ggplot2)
library(lattice)
library(latticeExtra)
########################################
### Figure 2: FDI in India Over Time ###
########################################
# Load Figure 2 top panel data.
fig2top_data <- read.csv("fig2top_data.csv")
# Set panel parameters for a double-paneled figure.
par(mfrow=c(2,1))
# Plot top panel of Figure 2.
plot(fig2top_data$x~as.integer(fig2top_data$year),xlab="year",ylab="rupees (2011 constant millions)",type="l",lty=1,lwd=2, sub="Completed Greenfield FDI Projects (Source: CapEx)")
abline(v=2006,col="red",lty=1)
# Load Figure 2 bottom panel data.
fig2bot_data <- read.csv("fig2bot_data.csv")
# Plot bottom panel of Figure 2.
plot(fig2bot_data$x~fig2bot_data$year,xlab="year",ylab=" US$ (millions)",type="l",lty=2,lwd=2,sub=" Official Data on Greenfield FDI Inflows (Source: RBI)")
abline(v=2006,col="red",lty=1)
